// 运营中心
import Vue from "vue";
import API from "../requestApi/taskApi";
import { get, post } from "../requestApi/request";
const task = {
  // 新建任务
  getapiTaskPublish: function getapiTaskPublish(params) {
    return Vue.http.post(API.apiTaskPublish, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 新建子任务
  getapiTaskPublishsub: function getapiTaskPublishsub(params) {
    return Vue.http.post(API.apiTaskPublishsub, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 我的任务列表
  getapiTaskMyList: function getapiTaskMyList(params) {
    return Vue.http.post(API.apiTaskMyList, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 查验任务列表
  getapiTaskCheckList: function getapiTaskCheckList(params) {
    return Vue.http.post(API.apiTaskCheckList, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 任务详情
  getapiTaskInfo: function getapiTaskInfo(params) {
    let ip = `${API.apiTaskInfo}?memberId=${params.memberId}&taskId=${
      params.taskId
    }`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 更改任务状态
  gettaskupdatestatus: function gettaskupdatestatus(params) {
    return Vue.http.post(API.taskupdatestatus, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 拆分任务列表
  getapiTaskResolutionList: function getapiTaskResolutionList(params) {
    let ip = `${API.apiTaskResolutionList}?memberId=${params.memberId}`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 子任务列表
  getapiTaskSubList: function getapiTaskSubList(params) {
    let ip = `${API.apiTaskSubList}?memberId=${params.memberId}&taskId=${
      params.taskId
    }`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 发送计划
  getapiplansave: function getapiplansave(params) {
    return Vue.http.post(API.apiplansave, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 计划详情
  getapiplanget: function getapiplanget(params) {
    let ip = `${API.apiplanget}?memberId=${params.memberId}&type=${
      params.type
    }`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 添加汇报时任务列表
  getapiplantasklist: function getapiplantasklist(params) {
    let ip = `${API.apiplantasklist}?planId=${params.planId}&taskIds=${
      params.taskIds
    }&memberId=${params.memberId}&type=${params.type}`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 添加计划时任务列表
  getapiplanappendtasklist: function getapiplanappendtasklist(params) {
    let ip = `${API.apiplanappendtasklist}?planId=${params.planId}&memberId=${
      params.memberId
    }`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 添加汇报时追加任务
  getapiplanappendtask: function getapiplanappendtask(params) {
    return Vue.http.post(API.apiplanappendtask, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 判断是否存在计划
  getreportindex: function getreportindex(params) {
    let ip = `${API.reportindex}?memberId=${params.memberId}`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 提交保存日汇报
  getreportsubmit: function getreportsubmit(params) {
    return Vue.http.post(API.reportsubmit, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 收到的汇报
  getreportreceivedpage: function getreportreceivedpage(params) {
    return Vue.http.post(API.reportreceivedpage, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 发出的汇报
  getreportsentpage: function getreportsentpage(params) {
    return Vue.http.post(API.reportsentpage, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 任务列表
  gethometasklist: function gethometasklist(params) {
    return Vue.http.post(API.hometasklist, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 更新新增任务状态已读状态
  gethometaskreadstatus: function gethometaskreadstatus(params) {
    return Vue.http.post(API.hometaskreadstatus, params).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 汇报详情
  getreportdetail: function getreportdetail(params) {
    let ip = `${API.reportdetail}?memberId=${params.memberId}&reportId=${
      params.reportId
    }`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 汇报详情列表
  getreportcount: function getreportcount(params) {
    let ip = `${API.reportcount}?memberId=${params.memberId}&reportId=${
      params.reportId
    }&type=${params.type}`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 修改已读未读状态
  getreportreadStatus: function getreportreadStatus(params) {
    let ip = `${API.reportreadStatus}?memberId=${params.memberId}&reportId=${
      params.reportId
    }&type=${params.type}`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 任务列表，供新建计划时用
  getreporttasklistnew: function getreporttasklistnew(params) {
    let ip = `${API.reporttasklistnew}?memberId=${params.memberId}&taskIds=${
      params.taskIds
    }`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  },
  // 汇报详情列表
  getstatisticscounttasklist: function getstatisticscounttasklist(params) {
    let ip = `${API.statisticscounttasklist}?id=${params.id}&type=${
      params.type
    }&no=${params.no}`;
    return Vue.http.get(ip, {}).then(response => {
      if (response.status === 200) {
        return Promise.resolve(response.body);
      } else {
        return Promise.reject(response.data);
      }
    });
  }
};
export default task;
